home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tcclib.exe / STRISTR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-07  |  581 b   |  26 lines

  1. #include <ctype.h>
  2. #include <string.h>
  3. #include <alloc.h>
  4.  
  5. char *stristr ( char *string1, char *string2 )
  6. {
  7.     char *cp;
  8.  
  9.     cp = string2;
  10.     if ( *cp != '\0' ) {
  11.         while ( *string1 != '\0' && *cp != '\0' ) {
  12.             cp = string2;
  13.             while ( toupper (*string1) == toupper (*cp) && *string1 != '\0' && *cp != '\0' ) {
  14.                 ++string1;  ++cp;
  15.             }
  16.             ++string1;
  17.         }
  18.         if ( *cp == '\0' ) cp = string1 - strlen (string2) - 1;
  19.         else cp = NULL;
  20.     }
  21.     else cp = NULL;
  22.  
  23.     return (cp);
  24. }
  25.  
  26.